// 单例模式管理游戏状态
class GameState {
    private static final float MAX_DIFFERENTIATION = 800f;
    private static GameState instance;
    private float health = 100.0f;
    private float differentiation = 0.0f;
    private int currentStage = 0;

    private Embryo embryo = new Embryo(Main.WIDTH / 2f, Main.HEIGHT / 2f);

    private GameState() {
    }

    public static synchronized GameState getInstance() {
        if (instance == null) {
            instance = new GameState();
        }
        return instance;
    }

    // 重置游戏状态到初始值
    public void reset() {
        health = 100.0f;
        differentiation = 0.0f;
        currentStage = 0;
        embryo = new Embryo(Main.WIDTH/2f, Main.HEIGHT/2f);
    }

    public void updateHealth(float delta) {
        health = Math.max(0, Math.min(100, health + delta));
    }

    public void updateDifferentiation(float delta) {
        differentiation = Math.min(MAX_DIFFERENTIATION, differentiation + delta);
    }

    public boolean shouldUpgradeStage() {
        return differentiation >= (currentStage + 1) * 100f;
    }


    public Embryo getEmbryo() {
        return embryo;
    }


    // Getter/Setter
    public float getHealth() {
        return health;
    }

    public float getDifferentiation() {
        return differentiation;
    }

    public int getCurrentStage() {
        return currentStage;
    }

    public void setCurrentStage(int stage) {
        currentStage = stage;
        embryo.updateStage(stage);
    }

}

